package com.itheima.subway.info.manage.entry;

import com.itheima.subway.info.manage.controller.AddController;
import com.itheima.subway.info.manage.controller.CheckController;
import com.itheima.subway.info.manage.domain.ManagerMassage;
import com.itheima.subway.info.manage.domain.Managers;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class EntryClass {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //管理员登陆逻辑
        while (true) {
            System.out.println("请输入管理员工号：");
            String manId = sc.next();
            System.out.println("请输入管理员姓名：");
            String name = sc.next();
            int a = Integer.parseInt(manId);

            ArrayList<Managers> list = ManagerMassage.readManagers();
//            System.out.println(list);
            boolean flag = false;

            for (Managers managers : list) {
//                System.out.println(managers);
                String Id = managers.getManId();
//                int b = Integer.parseInt(Id);
//                System.out.println(manId);
//                System.out.println(Id);
                if (Id.equals(manId)) {
                    if (managers.getName().equals(name)) {
                        flag = true;
                        break;
                    }
                }
            }

            if (flag){
                System.out.println("登陆成功！");
                break;
            }else {
                System.out.println("您的输入有误，请重新输入！");
            }
        }

        while (true) {
            System.out.println("1.查看地铁站 2.添加地铁站 3.退出系统");
            int num = sc.nextInt();
            switch (num) {
                case 1:
//                    System.out.println("查看地铁站");
                    CheckController.checkSuvways();
                    break;
                case 2:
//                    System.out.println("添加地铁站");
                    AddController.addSubways();
                    break;
                case 3:
//                    System.out.println("退出系统");
                    System.exit(0);
                default:
                    System.out.println("您的输入有误，请重新输入！");
                    break;
            }
        }
    }


}


